How to pass assistant phone number to tool call?
# support
j
I have an assistant that handles inbound calls from multiple phone numbers. When the call starts, I need the assistant to call my API to get organization info for the phone number that the customer called on. I'm able to call my endpoint, but I'm having trouble passing the phone number that was called. It seems that the agent is not able to access that information. Part of my prompt looks like this:
Copy code
### Introduction  
1. Before you speak, fetch organization data with `getOrganizationData`, passing `{{assistant.number}}` as `calledNumber`, so the request body will look like this:

{
  "calledNumber": "{{assistant.number}}"
}
ChatGPT suggested using
{{assistant.number}}
, but apparently that's not a valid Vapi variable. Is there another way that I can identify which phone number was called. Also, is there a place where we can see what Vapi variables are available? My fallback plan is to pass the callId, and then correlate that with a webhook event, but it doesn't seem to want to pass me
{{call.id}}
either. I am able to pass
{{caller.number}}
, so at least some Vapi variables are working, but that doesn't help me much for this specific use case. If I hardcode the number, the API call succeeds and returns data, so I know that everything about my configuration is correct, except for the passing of the called phone number. Thanks for any info you can provide.
v
You should use
{{customer.number}}
to reference the phone number that was called. Update your tool call payload like this:
Copy code
json
{
  "calledNumber": "{{customer.number}}"
}
This will dynamically insert the destination number for each inbound call, as supported by Vapi's variable system ([documentation](https://docs.vapi.ai/assistants/dynamic-variables#default-variables)). Source: - [Variables Vapi Documentation](https://docs.vapi.ai/assistants/dynamic-variables#default-variables)
j
@Vapi Support Bot The {{customer.number}} is the number that is being called from. I verified this by inspecting the value in my API call. I need to know the number that is being called on my inbound call.
v
Thank you for clarifying that
{{customer.number}}
returns the caller's number in your inbound scenario. To help pinpoint the issue, could you share whether you are using a custom server endpoint (Server URL) to handle inbound calls, and if so, are you able to see the called (destination) number in the webhook payload sent by Vapi? This will help determine if the number is accessible at the server level, even if not directly as a dynamic variable in the assistant prompt. Source: - [Variables Vapi Documentation](https://docs.vapi.ai/assistants/dynamic-variables#default-variables)
j
@Vapi Support Bot Yes, I am using a custom server endpoint and am receiving webhook events, where the called (destination) number is present in the payload. I just can't get my assistant to pass it in the tool call to my API endpoint.
@Vapi @Vapi Support Bot Any info you can provide on this would be appreciated.
c
Hey, I see you're having trouble passing the called number to your API endpoint. Can you let me know what specific issues you're encountering? That way, I can help you troubleshoot this better.
j
Hi @Praveen - Yes, I pretty much explained it in my original post, but when I try to call my tool endpoint and pass it
{{assistant.number}}
in the request body, I receive a null value. So how can I communicate which phone number was called to my tool endpoint? It would be helpful to know what are the Vapi variables that are available to my assistant to pass to tool calls.
c
Could you please provide a call id where you attempted to pass this dynamic variable from the request body? We would like to see the value that is in the tool
j
Here's an example callId:
16a3f65a-069e-407e-b53d-276f51214765
c
Try using {{phoneNumber.Number}}
Copy code
"phoneNumber": {
        "id": "5xxx36-xxxx-45dd-xxxx-c349xxxx0058",
        "name": "Dev Number",
        "orgId": "d3xxxxb5-xxxx-47a6-xxxx-865b5xxxxc26",
        "number": "+121xxxxx310",
        "server": {}
d
Did this work @John . I'm in the same situation
j
No, it didn't. I ended up going with a completely different approach. Instead of having a single assistant that handles calls for all of my orgs and trying to pass the called number to my API to resolve the org, I now have one assistant per org with the orgId hardcoded in the prompt, so that it can retrieve the org data from my API. I have a button on my org details screen in my app that POSTs the assistant to Vapi, with the orgId hardcoded in the assistant prompt.
h
It works for me. I have several AI assistants which share the same set of tools. I needed a way to pass the assistant’s phone number to each shared tool. So I followed what Kyle suggested and used {{phoneNumber.number}} as a property in the shared tools. I also added this text in my prompt as well: “Your phone number is , which is {{phoneNumber.number}}
c
Glad you were able to get this resolved. If anything else comes up or you need further assistance, we’re here to help.
h
Update: It doesn’t work for me. Only works sometimes. I ended up giving the actual number itself in the prompt.
5 Views